package com.app.common.dataDictionary.PO;

import java.util.BitSet;
import java.util.HashMap;
import java.util.Map;

import com.app.common.dataDictionary.DE.DE_PARAM_ID;
import com.app.common.dataDictionary.DE.DE_PARAM_OPPTIME;
import com.app.common.dataDictionary.DE.DE_USERBRANDCLICKSINITVALUE;
import com.app.common.dataDictionary.DE.DE_USERSCANQRCODEINITVALUE;
import com.app.common.dataDictionary.DE.DE_USERWEALTHINITVALUE;
import com.css.sword.kernel.base.annotation.PersistObject;
import com.css.sword.kernel.base.dataElement.AbsPersistObject;
import com.css.sword.kernel.base.dataElement.BaseDataElement;
import com.css.sword.kernel.base.dataElement.DateDE;
import com.css.sword.kernel.base.exception.SwordBaseCheckedException;


/**
 * 应用系统参数维护表; InnoDB free: 11264 kB
 */
@PersistObject
public class TParamMaintainPO extends AbsPersistObject {
	//private static final long serialVersionUID = 386962042556571244L;
	private static final long serialVersionUID = 1L;
	private static final BitSet HAS_DEFAULT_VALUE = new BitSet(5);
	
	static{
	}
	
	/**
	 * 物理表名
	 */
	public static final String TABLE_NAME = "t_param_maintain";

	/**
	 * 主键id
	 */
	private DE_PARAM_ID paramId = DE_PARAM_ID.getTemplateInstance();

	/**
	 * 用户每天对所有品牌可点击次数
	 */
	private DE_USERBRANDCLICKSINITVALUE userbrandclicksinitvalue = DE_USERBRANDCLICKSINITVALUE.getTemplateInstance();

	/**
	 * 用户注册后初始化财富值
	 */
	private DE_USERWEALTHINITVALUE userwealthinitvalue = DE_USERWEALTHINITVALUE.getTemplateInstance();

	/**
	 * 用户每天对所有二维码可扫描次数
	 */
	private DE_USERSCANQRCODEINITVALUE userscanqrcodeinitvalue = DE_USERSCANQRCODEINITVALUE.getTemplateInstance();

	/**
	 * 手机应用参数维护操作时间
	 */
	private DE_PARAM_OPPTIME paramOpptime = DE_PARAM_OPPTIME.getTemplateInstance();


	public TParamMaintainPO(){
		this.insertState = new BitSet(5);
		this.updateState = new BitSet(5);
	}

	
	/**
	 * 获取 "主键id" 值
	 */	
	public DE_PARAM_ID getParamId(){
		return  paramId;
	}
	
	/**
	 * 设置 "主键id" 值
	 */
	public void setParamId(DE_PARAM_ID paramId) {
		if(paramId == null){
			paramId= DE_PARAM_ID.getTemplateInstance();
		}
		recordChangeFlag(0);
		this.paramId = paramId;
	}
	
	/**
	 * 获取 "用户每天对所有品牌可点击次数" 值
	 */	
	public DE_USERBRANDCLICKSINITVALUE getUserbrandclicksinitvalue(){
		return  userbrandclicksinitvalue;
	}
	
	/**
	 * 设置 "用户每天对所有品牌可点击次数" 值
	 */
	public void setUserbrandclicksinitvalue(DE_USERBRANDCLICKSINITVALUE userbrandclicksinitvalue) {
		if(userbrandclicksinitvalue == null){
			userbrandclicksinitvalue= DE_USERBRANDCLICKSINITVALUE.getTemplateInstance();
		}
		recordChangeFlag(1);
		this.userbrandclicksinitvalue = userbrandclicksinitvalue;
	}
	
	/**
	 * 获取 "用户注册后初始化财富值" 值
	 */	
	public DE_USERWEALTHINITVALUE getUserwealthinitvalue(){
		return  userwealthinitvalue;
	}
	
	/**
	 * 设置 "用户注册后初始化财富值" 值
	 */
	public void setUserwealthinitvalue(DE_USERWEALTHINITVALUE userwealthinitvalue) {
		if(userwealthinitvalue == null){
			userwealthinitvalue= DE_USERWEALTHINITVALUE.getTemplateInstance();
		}
		recordChangeFlag(2);
		this.userwealthinitvalue = userwealthinitvalue;
	}
	
	/**
	 * 获取 "用户每天对所有二维码可扫描次数" 值
	 */	
	public DE_USERSCANQRCODEINITVALUE getUserscanqrcodeinitvalue(){
		return  userscanqrcodeinitvalue;
	}
	
	/**
	 * 设置 "用户每天对所有二维码可扫描次数" 值
	 */
	public void setUserscanqrcodeinitvalue(DE_USERSCANQRCODEINITVALUE userscanqrcodeinitvalue) {
		if(userscanqrcodeinitvalue == null){
			userscanqrcodeinitvalue= DE_USERSCANQRCODEINITVALUE.getTemplateInstance();
		}
		recordChangeFlag(3);
		this.userscanqrcodeinitvalue = userscanqrcodeinitvalue;
	}
	
	/**
	 * 获取 "手机应用参数维护操作时间" 值
	 */	
	public DE_PARAM_OPPTIME getParamOpptime(){
		return  paramOpptime;
	}
	
	/**
	 * 设置 "手机应用参数维护操作时间" 值
	 */
	public void setParamOpptime(DE_PARAM_OPPTIME paramOpptime) {
		if(paramOpptime == null){
			paramOpptime= DE_PARAM_OPPTIME.getTemplateInstance();
		}
		recordChangeFlag(4);
		this.paramOpptime = paramOpptime;
	}


	@Override
	public BaseDataElement<?>[] fields(){
		return new BaseDataElement<?>[] {paramId,userbrandclicksinitvalue,userwealthinitvalue,userscanqrcodeinitvalue,paramOpptime};
	}
	
	@Override
	public String[] fieldNames() {
		return new String[]{"paramId","userbrandclicksinitvalue","userwealthinitvalue","userscanqrcodeinitvalue","paramOpptime"};
	}
	
	@Override
	public BaseDataElement<?> getFieldValue(String fieldName)  {
		if ("paramId".equals(fieldName)) {
			return paramId;
		}
		if ("userbrandclicksinitvalue".equals(fieldName)) {
			return userbrandclicksinitvalue;
		}
		if ("userwealthinitvalue".equals(fieldName)) {
			return userwealthinitvalue;
		}
		if ("userscanqrcodeinitvalue".equals(fieldName)) {
			return userscanqrcodeinitvalue;
		}
		if ("paramOpptime".equals(fieldName)) {
			return paramOpptime;
		}
 
		throw new IllegalArgumentException("PO对象中没有"+fieldName+"字段");
	}
	
	@Override
	public TParamMaintainPO setFieldValue(String fieldName, Object fieldValue) throws SwordBaseCheckedException {
		if (fieldValue != null && !(fieldValue instanceof BaseDataElement<?>)) {
			throw new SwordBaseCheckedException("字段值类型不是DataElelement子类型");
		}

		if ("paramId".equals(fieldName)) {
			if (fieldValue == null) {
				setParamId(null);
			} else {
				setParamId((DE_PARAM_ID) fieldValue);
			}
			return this;
		}

		if ("userbrandclicksinitvalue".equals(fieldName)) {
			if (fieldValue == null) {
				setUserbrandclicksinitvalue(null);
			} else {
				setUserbrandclicksinitvalue((DE_USERBRANDCLICKSINITVALUE) fieldValue);
			}
			return this;
		}

		if ("userwealthinitvalue".equals(fieldName)) {
			if (fieldValue == null) {
				setUserwealthinitvalue(null);
			} else {
				setUserwealthinitvalue((DE_USERWEALTHINITVALUE) fieldValue);
			}
			return this;
		}

		if ("userscanqrcodeinitvalue".equals(fieldName)) {
			if (fieldValue == null) {
				setUserscanqrcodeinitvalue(null);
			} else {
				setUserscanqrcodeinitvalue((DE_USERSCANQRCODEINITVALUE) fieldValue);
			}
			return this;
		}

		if ("paramOpptime".equals(fieldName)) {
			if (fieldValue == null) {
				setParamOpptime(null);
			} else {
				setParamOpptime((DE_PARAM_OPPTIME) fieldValue);
			}
			return this;
		}

		throw new SwordBaseCheckedException("PO对象中没有"+fieldName+"字段");
	}

	@Override
	protected TParamMaintainPO clone() {
		TParamMaintainPO t = new TParamMaintainPO();
		
		t.setParamId(this.paramId);
		t.setUserbrandclicksinitvalue(this.userbrandclicksinitvalue);
		t.setUserwealthinitvalue(this.userwealthinitvalue);
		t.setUserscanqrcodeinitvalue(this.userscanqrcodeinitvalue);
		t.setParamOpptime(this.paramOpptime);

		return t;
	}

	@Override
	public TParamMaintainPO loadMap(Map<String, Object> dataMap) throws SwordBaseCheckedException {
		Object value = null;

		if(dataMap.containsKey("paramId")){
			value = dataMap.get("paramId");
			
			if (value == null) {
				this.setParamId(null);
			} else {
				if (value instanceof DE_PARAM_ID) {
					this.setParamId((DE_PARAM_ID) value);
				}
			    else {
					this.setParamId(new DE_PARAM_ID(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("userbrandclicksinitvalue")){
			value = dataMap.get("userbrandclicksinitvalue");
			
			if (value == null) {
				this.setUserbrandclicksinitvalue(null);
			} else {
				if (value instanceof DE_USERBRANDCLICKSINITVALUE) {
					this.setUserbrandclicksinitvalue((DE_USERBRANDCLICKSINITVALUE) value);
				}
			    else {
					this.setUserbrandclicksinitvalue(new DE_USERBRANDCLICKSINITVALUE(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("userwealthinitvalue")){
			value = dataMap.get("userwealthinitvalue");
			
			if (value == null) {
				this.setUserwealthinitvalue(null);
			} else {
				if (value instanceof DE_USERWEALTHINITVALUE) {
					this.setUserwealthinitvalue((DE_USERWEALTHINITVALUE) value);
				}
			    else {
					this.setUserwealthinitvalue(new DE_USERWEALTHINITVALUE(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("userscanqrcodeinitvalue")){
			value = dataMap.get("userscanqrcodeinitvalue");
			
			if (value == null) {
				this.setUserscanqrcodeinitvalue(null);
			} else {
				if (value instanceof DE_USERSCANQRCODEINITVALUE) {
					this.setUserscanqrcodeinitvalue((DE_USERSCANQRCODEINITVALUE) value);
				}
			    else {
					this.setUserscanqrcodeinitvalue(new DE_USERSCANQRCODEINITVALUE(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("paramOpptime")){
			value = dataMap.get("paramOpptime");
			
			if (value == null) {
				this.setParamOpptime(null);
			} else {
				if (value instanceof DE_PARAM_OPPTIME) {
					this.setParamOpptime((DE_PARAM_OPPTIME) value);
				}
				else if(value instanceof java.util.Date){
					this.setParamOpptime(new DE_PARAM_OPPTIME((java.util.Date)value));
				}
			    else {
					this.setParamOpptime(new DE_PARAM_OPPTIME(value.toString()));
				}
			}
		}

		return this;
	}
	
	@Override
	public Map<String,Object> toMap() {
		Map<String,Object> dataMap = new HashMap<String,Object>();

		dataMap.put("paramId", paramId);
		dataMap.put("userbrandclicksinitvalue", userbrandclicksinitvalue);
		dataMap.put("userwealthinitvalue", userwealthinitvalue);
		dataMap.put("userscanqrcodeinitvalue", userscanqrcodeinitvalue);
		dataMap.put("paramOpptime", paramOpptime);
		
		return dataMap;
	}
	
	@Override
	public Map<String,Object> toMapWithDEValue() {
		Map<String,Object> dataMap = new HashMap<String,Object>();

		dataMap.put("paramId", (paramId==null?null:paramId.value));
		dataMap.put("userbrandclicksinitvalue", (userbrandclicksinitvalue==null?null:userbrandclicksinitvalue.value));
		dataMap.put("userwealthinitvalue", (userwealthinitvalue==null?null:userwealthinitvalue.value));
		dataMap.put("userscanqrcodeinitvalue", (userscanqrcodeinitvalue==null?null:userscanqrcodeinitvalue.value));
		dataMap.put("paramOpptime", (paramOpptime==null?null:paramOpptime.value));
		
		return dataMap;
	}
	
	@Override
	public TParamMaintainPO newInstance() {
		return new TParamMaintainPO();
	}
	
	@Override
	public String getTableName(){
		return TABLE_NAME;
	}
	
	@Override
	public BaseDataElement<?>[] getPrimaryKey() {
		return new BaseDataElement<?>[]{paramId};
	}

	@Override
	public void checkNotNull(byte sqlType) throws SwordBaseCheckedException {
		StringBuilder errorMsg = new StringBuilder();
		// insert
		if (sqlType == 0) {
				//只校验不可为空但又没有默认值的字段
				if (paramId.value == null && !HAS_DEFAULT_VALUE.get(0)) {
					errorMsg.append("字段paramId不允许为空\n");
				}

		}
		// update
		else if (sqlType == 1) {
		if (updateState.get(0) && paramId.value == null) {
			errorMsg.append("字段paramId不允许为空\n");
		}

		}
		
		if (errorMsg.length() > 0) {
			errorMsg.setLength(errorMsg.length() - 1);
			throw new SwordBaseCheckedException(errorMsg.toString());
		}
	}

	@Override
	public void updateLrrq(DateDE lrrq) {
	}

	@Override
	public void updateXgrq(DateDE xgrq) {
	}

	@Override
	public String toString() {
		StringBuilder str = new StringBuilder();
		str.append("paramId:").append(paramId.value!=null?paramId:"").append(" ").append("userbrandclicksinitvalue:").append(userbrandclicksinitvalue.value!=null?userbrandclicksinitvalue:"").append(" ").append("userwealthinitvalue:").append(userwealthinitvalue.value!=null?userwealthinitvalue:"").append(" ").append("userscanqrcodeinitvalue:").append(userscanqrcodeinitvalue.value!=null?userscanqrcodeinitvalue:"").append(" ").append("paramOpptime:").append(paramOpptime.value!=null?paramOpptime:"").append(" ");
		return str.toString();
	}
	
}
